/**
 * 多标签页
 * */
import { get } from 'lodash';
import FingerprintJS from "../../../libs/vendor/fp";

// 判定是否需要缓存
const isKeepAlive = data => get(data, 'meta.cache', false);
export default {
    namespaced: true,
    state: {
        visitorId : ""
    },
    actions: {
        /**
         * @class pool
         * @param {Object} state vuex state
         * @param {Array} routes routes
         */
        async init({state, dispatch}) {
            let visitorId = localStorage.getItem("visitorId");
            if (visitorId == null) {
                var fpPromise = FingerprintJS.load();
                fpPromise.then(fp => fp.get()).then(result => {
                    const visitorId = result.visitorId;
                    state.visitorId = visitorId;
                    localStorage.setItem("visitorId",visitorId);
                });
            } else {
                state.visitorId = visitorId;
            }
        }
    }
}
